/*
 * GoMokuView.java
 */

package gomoku;

import gomoku.NetworkAdapter.GoMokuGameLogic;
import org.jdesktop.application.Action;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import gomoku.Model.Point;
import gomoku.Model.GoMokuGameType;


/**
 * The application's main frame.
 */
public class GoMokuAppView extends FrameView implements GoMokuActionListener {

    public static JFrame topFrame;

    public GoMokuAppView(SingleFrameApplication app) {
        super(app);
        initComponents();

        GoMokuAppView.topFrame = this.getFrame();
        GoMokuAppView.topFrame.setTitle("GoMoku Game");
        GoMokuAppView.topFrame.setResizable(false);

        gamePanel.registerMoveHandler(gamePanel);
        gamePanel.registerMoveHandler(this);
        
    }

    public void makeMove(Point location) {
    }
    
    public void newGame(GoMokuGameType type) {
    }
    
    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = GoMokuApp.getApplication().getMainFrame();
            aboutBox = new GoMokuAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        GoMokuApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        newMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        gamePanel = new gomoku.GamePanel();

        menuBar.setName("menuBar"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(gomoku.GoMokuApp.class).getContext().getResourceMap(GoMokuAppView.class);
        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(gomoku.GoMokuApp.class).getContext().getActionMap(GoMokuAppView.class, this);
        newMenuItem.setAction(actionMap.get("startNewGame")); // NOI18N
        newMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        newMenuItem.setMnemonic('N');
        newMenuItem.setText(resourceMap.getString("newMenuItem.text")); // NOI18N
        newMenuItem.setName("newMenuItem"); // NOI18N
        fileMenu.add(newMenuItem);

        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        gamePanel.setName("gamePanel"); // NOI18N

        setComponent(gamePanel);
        setMenuBar(menuBar);
    }// </editor-fold>//GEN-END:initComponents


    @Action
    public void startNewGame() {
        gamePanel.newGame(GoMokuGameType.UserVSComputer);
    }



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private gomoku.GamePanel gamePanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem newMenuItem;
    // End of variables declaration//GEN-END:variables


    private JDialog aboutBox;
}
